//
//  MyAssetsViewTableViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/15.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "MyAssetsViewTableViewCell.h"

@interface MyAssetsViewTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel; // 标题
@property (nonatomic, strong) UILabel *detailLabel; // 时间
@property (nonatomic, strong) UILabel *moneyNumLabel; // 金额
@end

@implementation MyAssetsViewTableViewCell
- (void)setDataDic:(NSDictionary *)dataDic
{
    self.titleLabel.text = dataDic[@"ordertitle"];
    self.detailLabel.text = dataDic[@"change_time"];
    self.moneyNumLabel.text = [NSString stringWithFormat:@"%@ 元",dataDic[@"amount"]];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsZero;
        
        [self.contentView addSubview:self.moneyNumLabel];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.detailLabel];
        
        __weak typeof(self)weakself = self;
        [self.moneyNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY);
            make.height.mas_offset(20 / HEIGHT_6S_SCALE);
            make.width.mas_offset(100 / WIDTH_6S_SCALE);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.mas_top).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(weakself.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_offset(20 / HEIGHT_6S_SCALE);
        }];
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakself.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.top.equalTo(weakself.titleLabel.mas_bottom);
            make.height.mas_offset(20 / HEIGHT_6S_SCALE);
        }];
        UIView *lineView = [[UIView alloc]init];
        lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakself.titleLabel.mas_left);
            make.right.equalTo(weakself);
            make.bottom.equalTo(weakself.mas_bottom).offset(-1 / HEIGHT_6S_SCALE);
            make.height.mas_offset(1 / HEIGHT_6S_SCALE);
        }];
    }
    return self;
}
#pragma mark - init
- (UILabel *)moneyNumLabel{
    if (!_moneyNumLabel) {
        _moneyNumLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _moneyNumLabel.backgroundColor = [UIColor clearColor];
        _moneyNumLabel.textColor = getColor(blackColor);
        _moneyNumLabel.textAlignment = NSTextAlignmentRight;
        _moneyNumLabel.font = DEF_FontSize_16;
        [_moneyNumLabel sizeToFit];
        _moneyNumLabel.text = @"-4.10 元";
    }
    return _moneyNumLabel;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = DEF_FontSize_16;
        [_titleLabel sizeToFit];
        _titleLabel.text = @"修下水道-支付";
    }
    return _titleLabel;
}
- (UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc] init];
        _detailLabel.textColor = getColor(textColor);
        _detailLabel.textAlignment = NSTextAlignmentLeft;
        _detailLabel.numberOfLines = 0;
        _detailLabel.font = DEF_FontSize_14;
        //[_detailLabel sizeToFit];
        _detailLabel.text = @"2018-06-17 06:02:01";
    }
    return _detailLabel;
}
@end
